//
//  EFSImportantInformationModel.m
//  luGongPro
//
//  Created by 王庆学 on 2017/8/24.
//  Copyright © 2017年 王庆学. All rights reserved.
//

#import "EFSImportantInformationModel.h"

@implementation EFSImportantInformationModel

- (NSNumber *)shareEnabled{
    if (_shareEnabled == nil){
        _shareEnabled = @(YES);
    }
    return _shareEnabled;
}

- (NSDate *)date {
    return [NSDate dateWithTimeIntervalSince1970:[self.publishTime longValue] / 1000];
}

- (BOOL)hasImage{
    return self.img && self.img.description.length > 7;
}

+ (NSDictionary *)JSONKeyPathsByPropertyKey{
    return @{
             @"activityId":@"id",
             @"shareEnabled":[NSNull null]
             };
}

+ (NSValueTransformer *)imgJSONTransformer
{
    return [MTLValueTransformer valueTransformerForName:MTLURLValueTransformerName];
}

+ (NSValueTransformer *)shareImgJSONTransformer{
    return [MTLValueTransformer valueTransformerForName:MTLURLValueTransformerName];
}

+ (NSValueTransformer *)galleryImgJSONTransformer
{
    return [MTLValueTransformer valueTransformerForName:MTLURLValueTransformerName];
}

+ (NSValueTransformer *)urlJSONTransformer
{
    return [MTLValueTransformer valueTransformerForName:MTLURLValueTransformerName];
}

+ (NSValueTransformer *)topAllocatedJSONTransformer
{
    return [MTLValueTransformer reversibleTransformerWithForwardBlock:^id(NSString * code) {
        return [code isEqualToString:@"true"] ? @YES : @NO;
    } reverseBlock:^id(id code) {
        return [NSString stringWithFormat:@"%@", code];
    }];
}

- (NSString *)content{
    return _content ? _content : @"";
}

#pragma mark YGRenderProtocol
- (NSString *)floorIdentifier{
    return @"YGWorldNewsCell";
}

@end
